//
// Created by 党清浩 on 2021/9/28.
//
#include <stdio.h>

int main() {

    int x;
    int i;
    int j;
    int temp;

    scanf("%d",&x);
    int arr[x];

    for ( i = 0; i < x; i++) {
        scanf("%d",&arr[i]);
    }
    printf("Before sort:");
    for (i = 0; i < x; i++) {
        printf("%-4d",arr[i]);
    }

    for (j = 0; j < x-1; j++) {
        for ( i = 0; i < x-1-j; i++) {
            if(arr[i]>arr[i+1]){
                temp=arr[i];
                arr[i]=arr[i+1];
                arr[i+1]=temp;
            }
        }
    }
    printf("\nAfter sort:");
    for (i = 0; i < x; i++) {
        printf("%-4d",arr[i]);
    }
    return 0;
}

